package com.jackrain.nea.omslocal.service;

import com.alibaba.fastjson.util.TypeUtils;
import com.jackrain.nea.web.query.QueryEngine;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @Discription: 获取各表 squnce
 * Created with IntelliJ IDEA.
 * @Author cs
 * @Date 2017/12/25 14:19
 */
@Slf4j
@Component
public class GetSqunceService {

    /**
     * 获取 squnce
     *
     * @return
     */
    public long getSqunce(String tableName) {

        String squnceSql = "select get_wsequences('" + tableName + "') as SEQ from dual";
        long resultId;
        try {
            resultId = TypeUtils.castToLong(QueryEngine.getInstance().doQueryOne(squnceSql));

        } catch (Exception e) {
            // 获取squnce 异常, 无法保存数据
            resultId = -1;
        }
        return resultId;
    }

}
